import Page
from Page import Service
from Base.Base import Base
from selenium.webdriver.common.by import By


class ServiceStoreselectPage(Base):
    """
    门店选择界面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.store_home_btn = (By.XPATH, Service.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.store_back_btn = (By.XPATH, Service.RESOURCE_ID.format('ivBack'))

        # 选择门店标题
        self.store_select_store_title_text = (By.XPATH, Service.store_select_title_text.format(""))

        # 门店定位图标
        self.store_select_positioning_icon = (By.XPATH, Service.store_select_position_icon.format(""))

        # 门店定位城市
        self.store_select_city_text = (By.XPATH, Service.store_select_position_text.format(""))

        # 门店列表选择框
        self.store_list_select_icon = (By.XPATH, Service.store_list_lift_select_img.format(""))

        # 门店列表封面
        self.store_list_select_cover_img = (By.XPATH, Service.store_list_lift_cover_img.format(""))

        # 门店标题公司名称
        self.store_list_introduction_title_text = (By.XPATH, Service.store_list_Store_introduction_name_text.format(""))

        # 门店位置
        self.store_list_store_address_text = (By.XPATH, Service.store_list_Store_introduction_address_text.format(""))

        # 门店距离
        self.store_list_distance_text = (By.XPATH, Service.store_list_Store_introduction_distance_text.format(""))

        # 电话按钮
        self.store_list_iphone_btn = (By.XPATH, Service.store_list_below_btn.format(""))

        # 导航按钮
        self.store_list_navigation_btn = (By.XPATH, Service.store_list_navigation_btn.format(""))

        # 确认按钮
        self.store_confirm_button_btn = (By.XPATH, Service.RESOURCE_ID.format("button"))

        # 暂无门店图标
        self.store_no_store_icon = (By.XPATH, Service.RESOURCE_ID.format("imageView"))

        # 暂无门店提示
        self.store_no_store_tip_text = (By.XPATH, Service.RESOURCE_ID.format("notdata_text"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.store_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.store_back_btn)

    def get_select_store_title(self, index=1):
        """
        获得选择门店标题

        inde默认为1
        :return:获取元素
        """
        self.store_select_store_title_text = (By.XPATH, Service.store_select_title_text.format(index))
        return self.find_element_o(self.store_select_store_title_text)

    def get_select_positioning(self, index=1):
        """
        获得选择门店图标

        index默认为1
        :return:获取元素
        """
        self.store_select_positioning_icon = (By.XPATH, Service.store_select_position_icon.format(index))
        return self.find_element_o(self.store_select_positioning_icon)

    def get_select_city(self, index=1):
        """
        获得选择门店城市

        index默认为1
        :return:获取元素
        """
        self.store_select_city_text = (By.XPATH, Service.store_select_position_text.format(index))
        return self.find_element_o(self.store_select_city_text)

    def click_select_city(self, index=1):
        """
        点击选择门店城市

        index默认为1
        :return:获取元素
        """
        self.store_select_city_text = (By.XPATH, Service.store_select_position_text.format(index))
        self.click_element(self.store_select_city_text)

    def click_list_select(self, index=1):
        """
        点击门店选择框

        index默认为1
        :return:None
        """
        self.store_list_select_icon = (By.XPATH, Service.store_list_lift_select_img.format(index))
        self.click_element(self.store_list_select_icon)

    def get_list_select(self, index=1):
        """
        获取门店选择框属性

        index默认为1
        :return:None
        """
        self.store_list_select_icon = (By.XPATH, Service.store_list_lift_select_img.format(index))
        return self.find_element_o(self.store_list_select_icon)

    def get_list_select_cover(self, index=1):
        """
        获得选择门店封面

        index默认为1
        :return:获取元素
        """
        self.store_list_select_cover_img = (By.XPATH, Service.store_list_lift_cover_img.format(index))
        return self.find_element_o(self.store_list_select_cover_img)

    def get_list_introduction_title(self, index=1):
        """
        获得选择门店标题

        index默认为1
        :return:获取元素
        """
        self.store_list_introduction_title_text = (By.XPATH, Service.store_list_Store_introduction_name_text.format(index))
        return self.find_element_o(self.store_list_introduction_title_text)

    def get_list_store_address(self, index=1):
        """
        获得选择门店地址

        index默认为1
        :return:获取元素
        """
        self.store_list_store_address_text = (By.XPATH, Service.store_list_Store_introduction_address_text.format(index))
        return self.find_element_o(self.store_list_store_address_text)

    def get_list_distance(self, index=1):
        """
        获得选择门店距离

        index默认为1
        :return:获取元素
        """
        self.store_list_distance_text = (By.XPATH, Service.store_list_Store_introduction_distance_text.format(index))
        return self.find_element_o(self.store_list_distance_text)

    def click_list_iphone(self, index=1):
        """
        点击电话按钮

        index默认为1
        :return:None
        """
        self.store_list_iphone_btn = (By.XPATH, Service.store_list_below_btn.format(index))
        self.click_element(self.store_list_iphone_btn)

    def click_list_navigation(self, index=1):
        """
        点击导航按钮

        index默认为1
        :return:None
        """
        self.store_list_navigation_btn = (By.XPATH, Service.store_list_navigation_btn.format(index))
        self.click_element(self.store_list_navigation_btn)

    def click_confirm_button(self):
        """
        点击确认按钮

        :return:None
        """
        self.click_element(self.store_confirm_button_btn)

    def get_confirm_button_enabled(self):
        """
        获取确认按钮状态

        :return:None
        """
        return self.find_element_o(self.store_confirm_button_btn)

    def get_no_store(self):
        """
        获取没有门店图标

        :return:None
        """
        return self.find_element_o(self.store_no_store_icon)

    def get_no_store_tip(self):
        """
        获取没有门店文案

        :return:None
        """
        return self.find_element_o(self.store_no_store_tip_text)

    def is_display_service_no_store(self):
        """
        是否含有门店

        :return: bool
        """
        return self.is_display(self.store_no_store_tip_text)

    def is_display_service_store(self):
        """
        是否进入门店选择界面

        :return: bool
        """
        return self.is_display(self.store_select_store_title_text)
